/*
 *接口编写处...
*如果接口需要做Action的权限验证，请在Action上使用属性
*如: [ApiActionPermission("T_VIEW_CON",Enums.ActionPermissionOptions.Search)]
 */
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VOL.Entity.DomainModels;
using VOL.Wms.IServices;
using VOL.WebApi.VOL.WebApi.Operator.Wms;

namespace VOL.Wms.Controllers
{
    public partial class T_VIEW_CONController
    {
        private readonly IT_VIEW_CONService _service;//访问业务代码
        private readonly IHttpContextAccessor _httpContextAccessor;

        [ActivatorUtilitiesConstructor]
        public T_VIEW_CONController(
            IT_VIEW_CONService service,
            IHttpContextAccessor httpContextAccessor
        )
        : base(service)
        {
            _service = service;
            _httpContextAccessor = httpContextAccessor;
        }
        [HttpGet, Route("SynchronizeContracts")]
        
        public IActionResult 同步招采平台合同()
        {

            if (T_VIEW_CONOperator.SynchronizeContracts())
            {
                return Content("1");
            }
            else
            {
                return Content("2");
            }

        }
        //[HttpGet, Route("GetPageDataById")]

        //public IActionResult GetPageDataById()
        //{
        //    T_VIEW_CON t_view_con = new T_VIEW_CON();

        //    t_view_con = VOL.WebApi.Operator.Wms.T_VIEW_CONOperator.GetPageDataByIdOperator();

        //    return t_view_con ;
        //}
        [HttpPost, Route("GetPageData")]
        public override ActionResult GetPageData([FromBody] PageDataOptions loadData)
        {
            //var list = Service.GetPageData(loadData).rows;
            ////获取ConnectionId
            //var key = "SignalR" + UserContext.Current.UserId;
            //var cid = _cacheService.Get(key);
            ////测试SignalR推送业务数据
            //if (!string.IsNullOrEmpty(cid))
            //    _hubContext.Clients.Client(cid).SendAsync("SellOrderData", list);


            return base.GetPageData(loadData);
        }
        [HttpPost, Route("GetPageDataById")]
        public  ActionResult GetPageDataById(PageDataOptions loadData)
        {
            if (loadData!=null)
            {
                T_VIEW_CON t_view_con = new T_VIEW_CON();
                // var list = Service.GetPageData(loadData).rows;
                if (loadData.Wheres!=null)
                {
                    var wheres = loadData.Wheres;
                    t_view_con = T_VIEW_CONOperator.GetPageDataByIdOperator(wheres);


                    return JsonNormal(t_view_con);
                }
                else
                {
                    return base.GetPageData(loadData);
                }
               
            }
            else
            {
                return base.GetPageData(loadData);
            }
              
        }

    }
}
